<?php
/**
 * User: xuanbang.wen
 * Date: 2019/12/20
 */

namespace App\Command\Tools;


use App\Service\Dict;
use App\Service\DictConstant;
use App\Service\DictGenerate;
use EchoPHP\Console\Command;

class GenerateDictJson extends Command {

    protected $signature = "tools:generateDictJson {dict : '选择字典,major|functype|indtype|certlist'} {debug? : 调试模式请输入1,默认关闭}";
    protected $description = '生成字典json';

    /*
     * 生成过程
     */
    public function handle() {
        $generator = new DictGenerate();
        $generator->debug = $this->argument('debug') == 1 ? true : false;
        $dictName = $this->input->getArgument('dict');
        $generator->generateJson($dictName);


        try {
            $generator->generateJson($dictName);
        } catch (Exception $e) {
            $this->output->error('json字典' . $dictName . '生成失败：' . $e->getMessage());
        }
        $this->output->success('字典生成完毕');
    }
}